package com.lanqiao.gxnushop.mapper;

import com.lanqiao.gxnushop.entity.FinancialRecords;
import com.lanqiao.gxnushop.valueObject.Financial;
import io.swagger.v3.oas.annotations.media.Schema;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

@Schema(description ="财务记录表")
@Mapper
public interface FinancialRecordsMapper {
    @Schema(description ="添加财务记录")
    @Insert("insert into financialRecords(recordId,storeId,record,description,date) values (#{recordId},#{storeId},#{record},#{description},now())")
    boolean add(FinancialRecords financialRecords);

    @Schema(description ="删除指定的财务记录")
    @Delete("delete from financialRecords where recordId=#{recordId}")
    boolean delete(String recordId);

    @Schema(description ="根据店铺id删除所有财务记录")
    @Delete("delete from financialRecords where storeId=#{storeId}")
    boolean deleteByStoreId(String storeId);

    @Schema(description ="根据财务记录id查询财务记录")
    @Select("select * from financialRecords where recordId=#{recordId}")
    FinancialRecords findById(String recordId);

    @Schema(description ="根据店铺id查询财务记录")
    @Select("select * from financialRecords where storeId=#{storeId}")
    ArrayList<FinancialRecords> findByStoreId(String storeId);

    @Schema(description ="更新财务记录")
    @Update("update financialRecords set record=#{record},description=#{description} where recordId=#{recordId}")
    boolean update(FinancialRecords financialRecords);

    /**店铺金额统计信息*/
    @SelectProvider(type = FinancialRecordsMapperProvide.class,method = "getListSql")
    ArrayList<Financial> list(Financial financial);
}
